/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.bar.carta.model;

import com.bar.carta.service.PlatoLocalServiceUtil;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.impl.BaseModelImpl;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.util.Date;

/**
 * @author pgonzalm
 */
public class PlatoClp extends BaseModelImpl<Plato> implements Plato {
	public PlatoClp() {
	}

	public Class<?> getModelClass() {
		return Plato.class;
	}

	public String getModelClassName() {
		return Plato.class.getName();
	}

	public long getPrimaryKey() {
		return _platoId;
	}

	public void setPrimaryKey(long primaryKey) {
		setPlatoId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_platoId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public long getPlatoId() {
		return _platoId;
	}

	public void setPlatoId(long platoId) {
		_platoId = platoId;
	}

	public long getTipoId() {
		return _tipoId;
	}

	public void setTipoId(long tipoId) {
		_tipoId = tipoId;
	}

	public Date getCreateDate() {
		return _createDate;
	}

	public void setCreateDate(Date createDate) {
		_createDate = createDate;
	}

	public boolean getActivo() {
		return _activo;
	}

	public boolean isActivo() {
		return _activo;
	}

	public void setActivo(boolean activo) {
		_activo = activo;
	}

	public long getImagen() {
		return _imagen;
	}

	public void setImagen(long imagen) {
		_imagen = imagen;
	}

	public float getPrecio() {
		return _precio;
	}

	public void setPrecio(float precio) {
		_precio = precio;
	}

	public void persist() throws SystemException {
		if (this.isNew()) {
			PlatoLocalServiceUtil.addPlato(this);
		}
		else {
			PlatoLocalServiceUtil.updatePlato(this);
		}
	}

	@Override
	public Plato toEscapedModel() {
		return (Plato)Proxy.newProxyInstance(Plato.class.getClassLoader(),
			new Class[] { Plato.class }, new AutoEscapeBeanHandler(this));
	}

	@Override
	public Object clone() {
		PlatoClp clone = new PlatoClp();

		clone.setPlatoId(getPlatoId());
		clone.setTipoId(getTipoId());
		clone.setCreateDate(getCreateDate());
		clone.setActivo(getActivo());
		clone.setImagen(getImagen());
		clone.setPrecio(getPrecio());

		return clone;
	}

	public int compareTo(Plato plato) {
		long primaryKey = plato.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		PlatoClp plato = null;

		try {
			plato = (PlatoClp)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = plato.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(13);

		sb.append("{platoId=");
		sb.append(getPlatoId());
		sb.append(", tipoId=");
		sb.append(getTipoId());
		sb.append(", createDate=");
		sb.append(getCreateDate());
		sb.append(", activo=");
		sb.append(getActivo());
		sb.append(", imagen=");
		sb.append(getImagen());
		sb.append(", precio=");
		sb.append(getPrecio());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(22);

		sb.append("<model><model-name>");
		sb.append("com.bar.carta.model.Plato");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>platoId</column-name><column-value><![CDATA[");
		sb.append(getPlatoId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>tipoId</column-name><column-value><![CDATA[");
		sb.append(getTipoId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createDate</column-name><column-value><![CDATA[");
		sb.append(getCreateDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>activo</column-name><column-value><![CDATA[");
		sb.append(getActivo());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>imagen</column-name><column-value><![CDATA[");
		sb.append(getImagen());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>precio</column-name><column-value><![CDATA[");
		sb.append(getPrecio());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private long _platoId;
	private long _tipoId;
	private Date _createDate;
	private boolean _activo;
	private long _imagen;
	private float _precio;
}